/* Margin Calculator Premium Redesign */

:root {
    --mc-primary: #4f46e5;
    --mc-primary-hover: #4338ca;
    --mc-orange: #d97706;
    --mc-orange-hover: #b45309;
    --mc-bg: #f8fafc;
    --mc-card-bg: #ffffff;
    --mc-border: #e2e8f0;
    --mc-text-main: #0f172a;
    --mc-text-muted: #64748b;
    --mc-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --mc-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --mc-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --mc-radius: 12px;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--mc-bg);
    color: var(--mc-text-main);
}

.header-section {
    margin-bottom: 32px;
}

.header-section h2 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: #1e293b;
    margin-bottom: 8px;
}

.header-section p {
    color: var(--mc-text-muted);
    font-size: 15px;
}

.layout-grid {
    display: flex;
    gap: 32px;
    align-items: flex-start;
}

.input-panel {
    flex: 1;
    min-width: 0;
}

.result-panel {
    width: 320px;
    flex-shrink: 0;
}

.sticky-wrapper {
    position: sticky;
    top: 20px;
}

.cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.premium-card {
    background: var(--mc-card-bg);
    border: 1px solid var(--mc-border);
    border-radius: var(--mc-radius);
    box-shadow: var(--mc-shadow-sm);
    transition: all 0.3s ease;
    overflow: hidden;
}

.premium-card:hover {
    box-shadow: var(--mc-shadow-md);
    border-color: #cbd5e1;
}

.card-header {
    padding: 16px 16px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #f1f5f9;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.icon-wrapper {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
}

.bg-blue { background-color: var(--mc-primary); }
.bg-orange { background-color: var(--mc-orange); }
.text-primary { color: var(--mc-primary); }
.text-orange { color: var(--mc-orange); }
.text-danger { color: #ef4444; }
.text-gray { color: var(--mc-text-muted); }
.text-sm { font-size: 12px; }

.card-body {
    padding: 16px;
}

.fg {
    margin-bottom: 12px;
}

.fg:last-child {
    margin-bottom: 0;
}

.fg label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: #334155;
}

.hint {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 400;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper input {
    width: 100%;
    padding: 8px 36px 8px 12px;
    border: 1px solid var(--mc-border);
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: all 0.2s;
    background: #f8fafc;
}

.input-wrapper input:focus {
    background: #ffffff;
    border-color: var(--mc-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.input-wrapper .unit {
    position: absolute;
    right: 12px;
    font-size: 14px;
    color: #94a3b8;
    font-weight: 500;
    pointer-events: none;
}

/* Custom Toggle Switch */
.toggle-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    color: #475569;
    user-select: none;
}

.toggle-checkbox input {
    display: none;
}

.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    background-color: #cbd5e1;
    border-radius: 20px;
    transition: background-color 0.2s;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.toggle-checkbox input:checked + .toggle-switch {
    background-color: var(--mc-primary);
}

.toggle-checkbox input:checked + .toggle-switch::after {
    transform: translateX(16px);
}

.divider {
    height: 1px;
    background-color: var(--mc-border);
    margin: 14px 0;
}

/* Product Name */
.product-name-section {
    background: var(--mc-card-bg);
    padding: 16px;
    border-radius: var(--mc-radius);
    border: 1px solid var(--mc-border);
    box-shadow: var(--mc-shadow-sm);
}
.product-name-section label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}
.product-name-section input {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--mc-border);
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: all 0.2s;
}
.product-name-section input:focus {
    border-color: var(--mc-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
.badge-optional {
    font-size: 10px;
    background: #e2e8f0;
    color: #475569;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
}

/* Simulation Box */
.simulation-box {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 16px;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.badge-calc {
    font-size: 10px;
    padding: 2px 6px;
    color: white;
    border-radius: 4px;
}

.bg-primary { background: var(--mc-primary); }
.bg-orange { background: var(--mc-orange); }

.sync-icon {
    text-align: center;
    color: #94a3b8;
    font-size: 20px;
    margin: 6px 0;
}

/* Result Card */
.result-card {
    padding: 20px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.result-card h3 {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 16px 0;
    text-align: center;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.primary-result span {
    font-size: 14px;
    color: #475569;
    font-weight: 500;
}

.primary-result strong {
    font-size: 24px;
    font-weight: 700;
    color: var(--mc-primary);
}

.secondary-result span {
    font-size: 13px;
    color: #64748b;
}

.secondary-result strong {
    font-size: 16px;
    font-weight: 600;
    color: #334155;
}

.flex-align {
    display: flex;
    align-items: center;
    gap: 4px;
}

.tooltip-icon {
    color: #94a3b8;
    cursor: help;
    transition: color 0.2s;
}

.tooltip-icon:hover {
    color: var(--mc-primary);
}

.btn-primary-large {
    width: 100%;
    padding: 14px;
    background: var(--mc-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}

.btn-primary-large:hover {
    background: var(--mc-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(79, 70, 229, 0.3);
}

.btn-primary-large:active {
    transform: translateY(0);
}

/* History Section */
.history-section {
    margin-top: 32px;
}

.table-responsive {
    overflow-x: auto;
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: right;
}

.modern-table th {
    background: #f8fafc;
    padding: 12px 16px;
    color: #475569;
    font-weight: 600;
    border-bottom: 1px solid var(--mc-border);
}

.modern-table th:first-child, .modern-table td:first-child {
    text-align: left;
}

.modern-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    vertical-align: middle;
}

.modern-table tr:last-child td {
    border-bottom: none;
}

.modern-table tr:hover td {
    background-color: #f8fafc;
}

.btn-load {
    background: #e0e7ff;
    color: var(--mc-primary);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-load:hover {
    background: #c7d2fe;
    color: var(--mc-primary-hover);
}

.btn-delete {
    background: #fee2e2;
    color: #ef4444;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-delete:hover {
    background: #fca5a5;
    color: #b91c1c;
}

/* Snackbar */
#snackbar {
    visibility: hidden;
    min-width: 250px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 8px;
    padding: 16px;
    position: fixed;
    z-index: 1000;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    font-size: 14px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

#snackbar.show {
    visibility: visible;
    animation: fadein 0.5s, fadeout 0.5s 2.5s;
}

@keyframes fadein {
    from {bottom: 0; opacity: 0;}
    to {bottom: 30px; opacity: 1;}
}

@keyframes fadeout {
    from {bottom: 30px; opacity: 1;}
    to {bottom: 0; opacity: 0;}
}

/* Responsive */
@media (max-width: 1024px) {
    .layout-grid {
        flex-direction: column;
    }
    .result-panel {
        width: 100%;
    }
}
@media (max-width: 768px) {
    .cards-grid {
        grid-template-columns: 1fr;
    }
}
